
export default {

    category: Blockly.Categories.control ,
    
    color: [
        Blockly.Colours.event.primary,
        Blockly.Colours.event.secondary,
        Blockly.Colours.event.tertiary
    ] ,

    previousStatement: false ,
    nextStatement: true ,

    eventHandle: true ,

    init() {
        this.appendDummyInput()
            .appendField("当WiFi")
            .appendField(new Blockly.FieldDropdown(() => {
                return [
                    ['连接成功' , 'connected'] ,
                ]
            }), 'status')
    } ,

    run (args: any[], util: any, runtime: any) {
    } ,

    coder: {
        JavaScript(block: any, coder: any) {
            
            let inner = ''
            let nextBlock = block.nextConnection && block.nextConnection.targetBlock()
            if(nextBlock) {
                inner = coder.blockToCode(nextBlock)
            }

            return `beapi.wifi.on('connected', async () => {
    ${inner}
})\n`
        }
    }
}
